package com.wise.service.cms.content.settings;

import com.wise.entities.content.Setting;
import com.wise.framework.dao.SqlSelect;
import com.wise.framework.daomodel.DaoList;
import com.wise.framework.validation.Precondition;
import com.wise.summer.v1.cms.content.settings.ListSettings;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.summerframework.model.SummerService;
import org.summerframework.model.SummerServiceBean;

import java.util.List;

import static com.wise.model.content.ContentErrMsgs.Err_000100010001;


/**
 * @author futao
 * @date 2019/06/17
 */
@Service
@Slf4j
@SummerService
public class ListSettingsService implements SummerServiceBean<ListSettings> {
    @Override
    public void sum(ListSettings summer) {
        Precondition.checkState(StringUtils.isNotEmpty(summer.getName()), Err_000100010001);
        SqlSelect select = SqlSelect.selec("*");
        select.fromClassName(Setting.class);
        select.eq(Setting._name, summer.getName());
        select.eqLang(Setting._lang);
        List<Setting> infoList = DaoList.s(Setting.class, select);
        summer.setSummerResult(infoList);
    }
}
